<template>
  <div>
    <!-- 导航栏 -->
    <van-nav-bar
      :title="comment.reply_count ? comment.reply_count + '条回复' : '暂无回复'"
    >
    <van-icon @click="$emit('close-popup')" slot="left" name="cross" />
    </van-nav-bar>
    <!-- /导航栏 -->
    <div class="scroll-box">
      <ComponentItem :comment="comment" />
        <van-cell title="全部回复" />
      <Commomlist :list="list" type="c" :source="comment.com_id + ''" />
    </div>
    <!-- 当前评论信息 -->
    <div class="post-warp">
      <van-button @click="isShowResults = true" round>评论</van-button>
    </div>
    <!-- 弹层 -->
    <van-popup v-model="isShowResults " position="bottom">
      <CommomPost @postSuccess="onpostSuccess" :isCommomPost="true" :target="comment.com_id + ''" />
    </van-popup>
  </div>
</template>

<script>
import ComponentItem from '@/components/comment-item'
import Commomlist from './common-list.vue'
import CommomPost from './comment-post.vue'
export default {
  data () {
    return {
      list: [],
      isShowResults: false
    }
  },
  props: {
    comment: {
      type: Object,
      required: true
    }
  },
  components: {
    ComponentItem,
    Commomlist,
    CommomPost
  },
  created () {

  },

  methods: {
    onpostSuccess (e) {
      this.isShowResults = false
      this.list.unshift(e)
    }
  }
}
</script>

<style scoped lang='less'>
  .post-warp {
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  .van-button {
    width: 640px;
    height: 80px;
  }
}
.scroll-box {
  width: 100%;
  position: absolute;
  top: 92px;
  bottom: 102px;
  overflow-y: scroll;
}
</style>
